package com.study.sbsummary.utils.i18n;

import org.springframework.http.HttpStatus;

import java.text.MessageFormat;
import java.util.Locale;

public enum ErrorCode {
    BAD_REQUEST("1123", HttpStatus.BAD_REQUEST);

    private String errorCode;
    private HttpStatus httpStatus;
    ErrorCode(String errorCode, HttpStatus httpStatus) {
        this.errorCode = errorCode;
        this.httpStatus = httpStatus;
    }

    public String errorCode() {
        return errorCode;
    }

    public HttpStatus httpStatus() {
        return httpStatus;
    }

    public String getLocalizedMessage(Object... args) {
        return getLocalizedMessage(Locale.getDefault(), args);
    }

    public String getLocalizedMessage(Locale locale, Object... args) {
        return MessageFormat.format(I18nUtil.getLocalizedString(locale,
                "plog",
                errorCode), args);
    }
}
